<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Nanozyme of AHUCM</title>
    <link href="{{ url_for('static', filename='layui/css/layui.css') }}" rel="stylesheet">
    <style>
        html, body {
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
        }

        body {
            background-image: url('http://tpass.ahtcm.edu.cn/tpass/comm/image/ahtcm_bg_3.jpg?1704528949024'); /* 替换为你的背景图片的文件路径 */
            background-size: 100% 100%;
            background-repeat: no-repeat;
            background-attachment: fixed;

            display: flex;
            justify-content: center;
            align-items: center;
        }
    </style>
</head>

<body>
<div style="margin-bottom: 500px; background-color:#fff; padding: 40px;">
    <form class="layui-form layui-form-pane" id="btn-submit">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">Username</label>
                <div class="layui-input-inline">
                    <input type="text" name="username" autocomplete="off"
                           class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">Password</label>
                <div class="layui-input-inline">
                    <input type="text" name="password" autocomplete="off"
                           class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item" style="width: 300px; padding: 0; margin: 0;">
            <button class="layui-btn" style="background-color: #336b03; float: left" lay-submit lay-filter="demo-login">
                Login
            </button>
            <button type="reset" class="layui-btn layui-btn-danger;"
                    style="margin-left: 106px;background-color: #3B99FC; float: right">Sign up
            </button>
        </div>
    </form>
</div>


<script src="{{ url_for('static', filename='layui/layui.js') }}"></script>
<script src="{{ url_for('static', filename='darkreader/darkreader.min.js') }}"></script>

<script>
    var CurrentUserName = 'NULL'

    layui.use(function () {
        var $ = layui.$;
        var form = layui.form;
        var layer = layui.layer;

        form.on('submit(demo-login)', function (data) {
            var input_username = data.field
            console.log(data.field)
            $.ajax({
                url: '/user/login',
                data: data.field,
                type: "post",
                dataType: 'json',
                success: function (result) {
                    // CurrentUserName = input_username;
                    // document.getElementById("userLink").innerText = CurrentUserName;
                    console.log(result)
                    layer.alert("Login Success", function () {
                        window.location.href = '/';
                    });
                },
                error: function () {
                    layer.alert("Wrong Password")
                }
            });
            return false;
        });
    })

</script>

</body>